package Util;

import java.text.ParseException;
import javax.swing.JFormattedTextField;
import javax.swing.text.MaskFormatter;

public class Mascaras {
            
    public static MaskFormatter maskData(JFormattedTextField textfield) throws ParseException{  
        MaskFormatter mask = new MaskFormatter("##/##/####");
        mask.setOverwriteMode(true);  
        mask.setValidCharacters("0123456789");  
        mask.setPlaceholderCharacter('_');
        mask.install(textfield);
        return mask;
    }
    
    public static MaskFormatter maskCPF(JFormattedTextField textfield) throws ParseException{  
        MaskFormatter mask = new MaskFormatter("###.###.###-##");
        mask.setOverwriteMode(true);  
        mask.setValidCharacters("0123456789");  
        mask.setPlaceholderCharacter('_');
        mask.install(textfield);
        return mask;
    }
    
    public static MaskFormatter maskTelefone(JFormattedTextField textfield) throws ParseException{  
        MaskFormatter mask = new MaskFormatter("(##)####-####");
        mask.setOverwriteMode(true);  
        mask.setValidCharacters("0123456789");  
        mask.setPlaceholderCharacter('_');
        mask.install(textfield);
        return mask;
    }
    
    public static MaskFormatter maskHora(JFormattedTextField textfield) throws ParseException{  
        MaskFormatter mask = new MaskFormatter("##:##");
        mask.setOverwriteMode(true);  
        mask.setValidCharacters("0123456789");  
        mask.setPlaceholderCharacter('_');
        mask.install(textfield);
        return mask;
    }
}
